﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 客户端
{
    public partial class 发票 : Form
    {
        public static string account;
        string date;
        public static string name, dj, sl, zje,jzfs;
        string constr = login.constr;
        public static string Coid; 
        public 发票()
        {
            InitializeComponent();
            SqlConnection sqlcon = new SqlConnection(constr);
            sqlcon.Open();
            string sql = "select Cname,Cnumber from Customer where Caccount='" + account + "'";
            SqlCommand sqlcmd = new SqlCommand(sql, sqlcon);
            SqlDataReader Sdr = sqlcmd.ExecuteReader();
            while (Sdr.Read())
            {
                label4.Text = Sdr["Cname"].ToString();   //姓名
                label6.Text = Sdr["Cnumber"].ToString();  //联系方式
            }
            sqlcon.Close();
            date=label12.Text = DateTime.Now.ToLocalTime().ToString(); //获取当前时间;   //发票日期
            sqlcon.Close();
            label25.Text = jzfs;  //支付方式
            label17.Text =name;
            label19.Text =sl;
            label21.Text =dj;
            label23.Text =zje;
            Random ra = new Random();
            string Ciid=ra.Next().ToString();//单号
            label8.Text = Ciid;
            string sql2 = "insert into Cinvoice(Ciid,Cidate,Caccount,Coid,Ciprice,Cimethod) values('"+Ciid+"','"+date+"','"+account+"','"+Coid+"','"+zje+"','"+jzfs+"')";
            sqlcon.Open();
            SqlCommand cmd = new SqlCommand(sql2, sqlcon);
            cmd.ExecuteNonQuery();
            sqlcon.Close();



        }
    }
}
